<template>
  <div class="detail-text">
    <div class="text-left" ref="textLeft">
      <svg class="icon svg-icon" aria-hidden="true" v-if="icon">
        <use :xlink:href="icon"></use>
      </svg>
      <span>{{text}}</span>
    </div>
    <div class="text-right">
      <span>{{distance}}</span>
      <van-icon :name="icon2"></van-icon>
    </div>
  </div>
</template>
<script>
export default {
  name: 'lTextRArrow',
  props: {
    icon: {
      type: String
    },
    text: {
      type: String
    },
    distance: {
      type: String
    },
    icon2: {
      type: String
    }
  },
  data() {
    return {}
  },
  mounted() {
    this.getWidth();
  },
  methods: {
    getWidth() {
      this.$refs.textLeft.style.width = this.$refs.textLeft.offsetWidth + 70 + 'px';
    }
  }
}
</script>
<style lang="scss" scoped>
.detail-text {
  width: 100%;
  height: $height*1.5;
  line-height: $height*1.5;
  display: flex;
  justify-content: space-between;
  border-bottom: 4px solid $bgcolor;
  padding-left: 15px;
  box-sizing: border-box;
  .text-left {
    width: auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    .svg-icon {
      color: $color;
    }
  }
  .text-right {
    padding-right: 20px;
    box-sizing: border-box;
    font-size: 12px;
    display: flex;
    align-items: center;
  }
}
</style>